Page({
  data: {
    currentTab: 0,
    len: 0,
    navArray: [{
        id: 0,
        navTitle: "品牌墙"
      }, {
        id: 1,
        navTitle: "国家墙"
      }, {
        id: 2,
        navTitle: "数码家电"
      }, {
        id: 3,
        navTitle: "美容彩妆"
      }, {
        id: 4,
        navTitle: "孕妈婴儿"
      }, {
        id: 5,
        navTitle: "营养保健"
      }, {
        id: 6,
        navTitle: "个人洗护"
      }, {
        id: 7,
        navTitle: "轻奢品牌"
      }, {
        id: 8,
        navTitle: "户外运动"
      }, {
        id: 9,
        navTitle: "家居生活"
      }, {
        id: 10,
        navTitle: "手表配饰"
      }, {
        id: 11,
        navTitle: "服饰鞋帽"
      },
      {
        id: 12,
        navTitle: "环球美食"
      },
      {
        id: 13,
        navTitle: "宠物生活"
      },
      {
        id: 14,
        navTitle: ""
      },
      {
        id: 15,
        navTitle: ""
      },
    ],
    cateTitleArray: ['奢侈品仓库'],
    cateArray: [{
      itemId: 0,
      itemImg: 'http://img3.imgtn.bdimg.com/it/u=1914880941,2560933384&fm=27&gp=0.jpg',
      itemName: '郑秀晶1'
    }, {
      itemId: 0,
      itemImg: 'http://img3.imgtn.bdimg.com/it/u=1914880941,2560933384&fm=27&gp=0.jpg',
      itemName: '郑秀晶2'
    }, {
      itemId: 0,
      itemImg: 'http://img3.imgtn.bdimg.com/it/u=1914880941,2560933384&fm=27&gp=0.jpg',
      itemName: '郑秀晶3'
    }],
    cateMiddleArray: [{
      itemId: 0,
      itemImg: 'http://img3.imgtn.bdimg.com/it/u=1914880941,2560933384&fm=27&gp=0.jpg',
      itemName: '郑秀晶4'
    }, {
      itemId: 0,
      itemImg: 'http://img3.imgtn.bdimg.com/it/u=1914880941,2560933384&fm=27&gp=0.jpg',
      itemName: '郑秀晶5'
    }],
    cateRightArray: [{
      itemId: 0,
      itemImg: 'http://img3.imgtn.bdimg.com/it/u=1914880941,2560933384&fm=27&gp=0.jpg',
      itemName: '郑秀晶6'
    }, {
      itemId: 0,
      itemImg: 'http://img3.imgtn.bdimg.com/it/u=1914880941,2560933384&fm=27&gp=0.jpg',
      itemName: '郑秀晶7'
    }],
    currentNavTab: 0
  },
  onLoad: function(option) {
    var that = this;
    var navArray = that.data.navArray;
    var len = 0;
    for (var i = 0; i < navArray.length; i++) {
      var navTitle = navArray[i].navTitle;
      if (navTitle != "") {
        len = len + 1;
      }
    }
    that.setData({
      len: len
    })
    console.log(len)
  },
  /**选择左侧标签 */
  selectNav: function(e) {
    console.log(e.currentTarget.id);
    var that = this;
    var index = parseInt(e.currentTarget.id);
    var currentNavTab = that.data.currentNavTab;
    var len = that.data.len;
    if (index < len) {
      that.setData({
        currentNavTab: index
      })
    }
  },
  /**跳转到搜索界面 */
  toSearchPage: function(e) {
    var that = this;
    var storeId = that.data.storeId;
    wx.navigateTo({
      url: '/pages/search/search' + '?storeId=' + storeId
    })
  },
  toSearchResult: function(e) {
    wx.navigateTo({
      url: '/pages/search_results/search_results',
    })
  },
  swichNav: function(e) {
    var that = this;
    if (that.data.currentTab === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentTab: e.target.dataset.current,
      })
    }
  },
});